package com.niit.ordersys.stub;

import com.niit.ordersys.pay.PaymentResult;
import com.niit.ordersys.pay.PaymentService;

public class PaymentServiceStub implements PaymentService {

    private boolean shouldSucceed;

    public PaymentServiceStub(boolean shouldSucceed) {
        this.shouldSucceed = shouldSucceed;
    }

    @Override
    public PaymentResult processPayment(String orderId, double amount) {
        // 返回预设的固定结果
        if (shouldSucceed) {
            return new PaymentResult(true, "STUB_12345", null);
        } else {
            return new PaymentResult(false, null, "Insufficient funds");
        }
    }
}
